package com.yunkaweilai.android.activity.operation;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.yunkaweilai.android.R;
import com.yunkaweilai.android.base.BaseActivity;
import com.yunkaweilai.android.fragment.order.OrderConsumptionFragment;
import com.yunkaweilai.android.fragment.order.OrderRechargeFragment;
import com.yunkaweilai.android.fragment.shop.CommodityInfoFragment;
import com.yunkaweilai.android.model.shop.ShopTypeModel;
import com.yunkaweilai.android.utils.TitleBuilder;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 我的订单记录
 * Created by Administrator on 2017/8/4.
 */

public class MyOrderListActivity extends BaseActivity {

    @BindView(R.id.id_tabLayout)
    TabLayout idTabLayout;
    @BindView(R.id.id_viewPager)
    ViewPager idViewPager;
    private String[] titls = new String[]{"消费记录", "充值记录"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order);
        ButterKnife.bind(this);
        new TitleBuilder(mAc).setTitleText("我的订单记录")
                .setLeftImage(R.mipmap.ic_go_back)
                .setLeftOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        finish();
                    }
                });
        OrderTypeAdapter adapter = new OrderTypeAdapter(getSupportFragmentManager());
        idViewPager.setAdapter(adapter);
        idTabLayout.setTabMode(TabLayout.MODE_FIXED);
        idTabLayout.setupWithViewPager(idViewPager);
    }
    class OrderTypeAdapter extends FragmentStatePagerAdapter {

        public OrderTypeAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titls[position];
        }

        @Override
        public Fragment getItem(int position) {
            Fragment fragment = null;
            if (position == 0){
                fragment = new OrderConsumptionFragment();
            }else if (position == 1){
                fragment = new OrderRechargeFragment();
            }
            return fragment;
        }

        @Override
        public int getCount() {
            return titls.length;
        }


    }
}
